import {PageInfoModel} from "./page-info.model";
import {PageParamsModel} from "./page-params.model";

export class InfiniteScrollModel {
    pageInfo: PageInfoModel = {
        pageNum: 1,
        pageSize: 20,
        total: 0,
        pages: 1,
        list: []
    };

    pageParams: PageParamsModel = {
        pageNum: 1,
        pageSize: 20,
        orderType: null,
        orderName: null,
        condition: {}
    };

    getNextPageData() {

    }

    /**
     *  加载组件回调
     * @param infiniteScroll
     */
    getMore(infiniteScroll) {
        if (this.pageInfo.list.length >= this.pageInfo.total) {
            console.log('没有更多了');
            infiniteScroll.enable();
        } else {
            this.pageParams.pageNum = this.pageInfo.pageNum + 1;
            infiniteScroll.waitFor(this.getNextPageData());
        }
    }
}
